<template>
	<uni-popup ref="popupRef" type="bottom">
		<view class="popup">
			<view class="popup-head flex-row">
				<text class="title">发送订单</text>
				<view @tap="close" class="close flex-column">
					<text class="iconfont icon-close"></text>
				</view>
			</view>
			<scroll-view class="popup-body" :scroll-y="true" :show-scrollbar="false">
				<view class="item flex-row" v-for="(item, index) in list" :key="index">
					<image class="image" :src="item.imageUrl" mode="aspectFill"></image>
					<view class="info">
						<view class="name text-ellipsis">{{ item?.name }}</view>
						<view class="price flex-row">
							<text class="unit">￥</text>
							<text class="value">{{ item?.amount }}</text>
							<text class="originPrice" v-if="item?.quantity">x{{ item?.quantity }}</text>
							<view class="btn" @tap="send(item)">发送</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</uni-popup>
</template>

<script setup>
import { ref } from 'vue'
import XBCCS from 'xbccs'

const emit = defineEmits(['send'])
const popupRef = ref(null)
const list = ref([])

function close(){
	popupRef.value?.close()
}

function send(goods){
	emit('send', goods)
	close()
}

defineExpose({
	open(){
		popupRef.value?.open()
		list.value = XBCCS.getOrderList()
	}
})

</script>

<style lang="scss" scoped>
@import url('./style.scss');

</style>